package com.ghh.encrypto.security;

public class CommonUtilities {
	public static boolean isEmpty(String s) {
		return s == null || s.trim().isEmpty();
	}

	public static String trim(String s) {
		return s == null ? s : s.trim();
	}

	public static int parsePort(String s, int defaultPort) {
		if (CommonUtilities.isEmpty(s)) {
			return defaultPort;
		} else {
			try {
				return Integer.valueOf(CommonUtilities.trim(s));
			} catch (NumberFormatException ne) {
				throw new NumberFormatException("Illegal port format");
			}
		}
	}

	public static int versionCompare(String v1, String v2) {
		return v1.compareTo(v2);
	}
}
